package cn.zy.jboa.util;

import java.util.List;

/**
 * 分页工具类
 * @author 
 *
 */
public class PageSupport {
	//当前页码-来自于用户输入
	private int currentPageNo = 1;
	
	//总数量（表）
	private int totalCount = 0;
	
	//页面容量
	private int pageSize = 1;
	
	//总页数-totalCount/pageSize（+1）
	private int totalPageCount = 1;
	
	//数据
	private List<?> items;

	public List<?> getItems() {
		return items;
	}

	public void setItems(List<?> items) {
		this.items = items;
	}

	public int getCurrentPageNo() {
		return currentPageNo;
	}

	/**
	 * @note 当前页号
	 * @author liuh
	 * */
	public void setCurrentPageNo(int currentPageNo) {
		if(currentPageNo > 0){
			this.currentPageNo = currentPageNo;
		}
	}

	public int getTotalCount() {
		return totalCount;
	}

	/**
	 * @note 总数据记录数
	 * @author liuh
	 * */
	public void setTotalCount(int totalCount) {
		if(totalCount > 0){
			this.totalCount = totalCount;
			//设置总页数
			this.setTotalPageCountByRs();
		}
	}
	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		if(pageSize > 0){
			this.pageSize = pageSize;
		}
	}

	/**
	 * @note 总页数
	 * @author liuh
	 * */
	public int getTotalPageCount() {
		return totalPageCount;
	}

	/*public void setTotalPageCount(int totalPageCount) {
		this.totalPageCount = totalPageCount;
	}*/
	
	/**
	 * @note 计算总页数
	 * @author liuh
	 * */
	private void setTotalPageCountByRs(){
		if(this.totalCount % this.pageSize == 0){
			this.totalPageCount = this.totalCount / this.pageSize;
		}else if(this.totalCount % this.pageSize > 0){
			this.totalPageCount = this.totalCount / this.pageSize + 1;
		}else{
			this.totalPageCount = 0;
		}
	}
	
}